package indexer;

import java.net.URI;

public class DocumentFactory {
	public static Document New(URI uri, String contentType) {
		Document newDoc = null;
		String mimeType = ParseMimeType(contentType).toLowerCase();

		if (mimeType.indexOf("text/") == 0) {
			newDoc = new HtmlDocument(uri, mimeType);
		} else if (mimeType == "application/javascript") {

		}

		return newDoc;
	}

	private static String ParseMimeType(String contentType) {
		String mimeType = "";
		String[] contentTypeArray = contentType.split(";");
		// Set MimeType if it's blank
		if (mimeType == "" && contentTypeArray.length >= 1) {
			mimeType = contentTypeArray[0];
		}
		return mimeType;
	}
}
